package api

import (
	"github.com/garyburd/redigo/redis"
	"github.com/kataras/iris"
	"github.com/ngaut/log"
	"server/bitkop/app/model"
	"server/bitkop/core"
)

func Index(ctx iris.Context) {
	ctx.Application().Logger().Info("info logger")
	ctx.StatusCode(400)
	log.Infof("maindb: %v", model.MainDB)

	conn := core.BK.Redis.OTEPool.Get()
	defer conn.Close()

	conn.Do("SET", "demo", "hello")

	result, err := redis.String(conn.Do("GET", "demo"))
	if err != nil {
		log.Errorf("err: %v", err)
	}

	ctx.JSON(map[string]interface{}{
		"code": 200,
		"msg":  "success",
		"user": model.UserModel.Get(1),
		"data": result,
	})
}
